﻿using System;
using System.Collections.Generic;

using System.Text;
using MVCFoto.IDAL;
using System.Data.SqlClient;
using System.Data;

namespace MVCFoto.SQLServerDAL
{
    public class Friend : IFriend
    {
        private const string PARM_USERID = "@UserID";
        private const string PARM_FRIENDID = "@FriendID";
        private const string PARM_ADDDATE = "@AddDate";
        public bool AddFriend(int userId, int friendId)
        {

            SqlParameter[] param = {
			SqlHelper.MakeInParam(PARM_USERID,SqlDbType.Int,4,userId),	
			SqlHelper.MakeInParam(PARM_FRIENDID,SqlDbType.Int,4,friendId),	
			SqlHelper.MakeInParam(PARM_ADDDATE,SqlDbType.DateTime,0,DateTime.Now)	
	        };
            return SqlHelper.ExecuteNonQuery("mfp_Insert_Friend", param) > 0 ? true : false;
        }
        public bool DeleteFriend(int userId, int friendId)
        {
            SqlParameter[] param = {
			SqlHelper.MakeInParam(PARM_USERID,SqlDbType.Int,4,userId),	
			SqlHelper.MakeInParam(PARM_FRIENDID,SqlDbType.Int,4,friendId)
			
	        };
            return SqlHelper.ExecuteNonQuery("mfp_Delete_Friend", param) > 0 ? true : false;
        }

        public bool IsUserFriend(int userId, int friendId)
        {
            SqlParameter[] param = {
			SqlHelper.MakeInParam(PARM_USERID,SqlDbType.Int,4,userId),	
			SqlHelper.MakeInParam(PARM_FRIENDID,SqlDbType.Int,4,friendId)
			
	        };
            return (int)SqlHelper.ExecuteOneValue("mfp_IsUserFriend", param) > 0 ? true : false;
        }
    }
}
